<?php

function foot_header($champ, $page)
{
	global $starttime;
	$starttime = microtime();
	$startarray = explode(" ", $starttime);
	$starttime = $startarray[1] + $startarray[0];
        $ret .= "<div id='principal'>";
        $ret .= "<div id='top'>";
        $ret .= "<A HREF='index.php'><img src='img/logo.gif'/></A>";
        $ret .= "</div>";
        $ret .= "<div id='nav_top'>";
	$ret .= navigation($champ, $page);
        $ret .= "</div>";
        return $ret;
}

function foot_footer($champ, $page)
{
        $ret .= "<div id='nav_bottom'>";
	$ret .= navigation($champ, $page);
        $ret .= "</div>";
	#$ret .= "<BR><SMALL>Contact: golaberto@gmail.com</SMALL>";
        $ret .= "</div>"; # principal
	$ret .= '<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"></script><script type="text/javascript">_uacct="UA-166590-2"; urchinTracker();</script>';
	global $starttime, $endtime;
	$endtime = microtime();
	$endarray = explode(" ", $endtime);
	$endtime = $endarray[1] + $endarray[0];
	$totaltime = $endtime - $starttime;
	$totaltime = round($totaltime,5);

	#$ret .= "<BR><CENTER>This page loaded in $totaltime seconds.</CENTER>";
	return $ret;
}

function navigation($champ, $page)
{
	if ($page === "table")
		$ret .= "<span class='nav_now'>Table</span> | ";
	else
		$ret .= "<A HREF=\"table.php?id=$champ\">Table</A> | ";

	if ($page === "team")
		$ret .= "<span class='nav_now'>Teams</span> | ";
	else
		$ret .= "<A HREF=\"team.php?champ=$champ\">Teams</A> | ";

	if ($page === "games")
		$ret .= "<span class='nav_now'>Games</span> | ";
	else
		$ret .= "<A HREF=\"games.php?id=$champ\">Games</A> | ";

	if ($page === "stats")
		$ret .= "<span class='nav_now'>Stats</span> | ";
	else
		$ret .= "<A HREF=\"stats.php?id=$champ\">Stats</A> | ";

	if ($page === "scorers")
		$ret .= "<span class='nav_now'>Top Scorers</span> | ";
	else
		$ret .= "<A HREF=\"scorers.php?id=$champ\">Top Scorers</A> | ";

	if ($page === "crowd")
		$ret .= "<span class='nav_now'>Avg Crowd</span> | ";
	else
		$ret .= "<A HREF=\"crowd.php?id=$champ\">Avg Crowd</A> | ";

	$ret .= "<A HREF=\"javascript:new_game($champ);\">Insert Game</A>";

	if (!$_SESSION["user"])
		$ret .= " | <A HREF=\"javascript:login();\">Login</A>";

	return $ret;
}
